package leetcode.sword;

public class Solution21 {

    public int[] exchange1(int[] nums) {
        int len = nums.length;
        if(len<2) return nums;
        int left = 0, right = len-1, tmp;
        while(left<right){
            while(left<right && (nums[left]&1)!=0) left++;
            while(left<right && (nums[right]&1)==0) right--;
            //交换
            tmp = nums[left];
            nums[left] = nums[right];
            nums[right] = tmp;
            left++; right--;
        }
        return nums;
    }



}
